{{ define "main" }}
{{ if .Parent.IsHome }}
{{ $.Scratch.Set "blog-pages" (where .Site.RegularPages "Section" .Section) }}
{{ else }}
{{$.Scratch.Set "blog-pages" .Pages }}
{{ end }}

<div class="td-content">
	{{- if .Pages -}}
		{{ $pag := .Paginate (( $.Scratch.Get "blog-pages").GroupByDate "2006")}}
			{{ range $pag.PageGroups }}
			<h2>{{ T "post_posts_in" }} {{ .Key }}</h2>
			<ul class="list-unstyled mt-4">
				{{ range .Pages }}
				<li class="media mb-4">
					<div class="media-body">
						<h3 class="mt-3 mb-1"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h5>
						<p class="mb-2 mb-md-3"><small class="text-muted">{{ .Date.Format ($.Param "time_format_blog") }}</small></p>
						{{ partial "featured-image.html" (dict "p" . "w" 250 "h" 125 "class" "float-left mr-3 pt-1 d-none d-md-block") }}
						<p class="pt-0 mt-0">{{ .Plain | safeHTML | truncate 250 }}</p>
					</div>
				</li>
				{{ end }}
			</ul>
			{{ end }}
		{{ end }}
		{{ if .Pages }}
			{{ template "_internal/pagination.html" . }}
		{{ end }}
</div>
{{ end }}